<template>
  <div>
    <el-row
      :span="24"
      class="body"
      style="margin-left: 0; margin-right: 0"
      :gutter="20"
    >
      <el-col
        :span="12"
        class="content"
        style="position: relative; padding: 0 !important"
      >
        <div id="charts1"   class="line"
             :style="{ width: '100%', margin: '0 auto' }"
             ref="charts1"></div>
      </el-col>
      <el-col
        :span="12"
        class="content"
        style="position: relative; padding: 0 !important"
      >
        <div id="charts2"   class="line"
             :style="{ width: '100%', margin: '0 auto' }"
             ref="charts2"></div>
      </el-col>
    </el-row>
    </div>
</template>

<script>
import * as echarts from "echarts";
export default{
 mounted() {
   this.drawChart1()  ;
   this.drawChart2();

 },
  methods:{
    //图表1
    drawChart1() {
      var chartDom = document.getElementById('charts1');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        title: {
          text: '药品统计',
          // subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '药品类型',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 5, name: '中药' },
              { value: 10, name: '西药' },
              { value: 3, name: '高血压类' },
              { value: 1, name: '心血管类' },
              { value: 9, name: '保健品' },
              { value: 4, name: '处方药' },
              { value: 1, name: '非处方药' }
    ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      option && myChart.setOption(option);
    },
    //图表2
    drawChart2() {
      var chartDom = document.getElementById('charts2');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        title: {
          text: '设备统计',
          // subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '设备类型',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 5, name: '办公设备' },
              { value: 24, name: '床位设备' },
              { value: 25, name: '摄像头' },
              { value: 3, name: '血压计' },
              { value: 4, name: '紧急按钮' }
    ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      option && myChart.setOption(option);
    },
  }
}
</script>

<style scoped>
.line{
  height: 1000px;
  padding: 10px;
}
</style>
